package 其他.两数之和167;

public class Solution {
    public int[] twoSum(int[] numbers, int target) {
        int left = 0;
        int right = numbers.length - 1;
        //题目有序，用二分查找答案
        while(true){
            int s = numbers[left] + numbers[right];
            if(s == target){
                return new int[]{left + 1, right + 1};
            }
            if(s > target){
                right --;
            }else{
                left ++;
            }
        }
    }
}
